<%--
  users.jsp
  作用：管理员后台的用户管理页面，展示所有用户列表，并提供封禁、解封、删除用户的功能。
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>用户管理</title>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/style.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/css/layout.css">
</head>
<body>

<div class="main-container">
    <jsp:include page="/WEB-INF/parts/sidebar.jsp" />

    <main class="content-area">
        <jsp:include page="/WEB-INF/parts/header.jsp" />

        <div class="page-title">
            <h2>用户管理</h2>
        </div>

        <c:if test="${not empty message}">
            <p class="success-message">${message}</p>
        </c:if>

        <div class="admin-table-container">
            <table class="admin-table">
                <thead>
                    <tr>
                        <th>ID</th>
                        <th>用户名</th>
                        <th>手机号</th>
                        <th>角色</th>
                        <th>状态</th>
                        <th>操作</th>
                    </tr>
                </thead>
                <tbody>
                    <c:forEach var="user" items="${users}">
                        <tr>
                            <td>${user.id}</td>
                            <td>${user.username}</td>
                            <td>${user.phone}</td>
                            <td>${user.role}</td>
                            <td><span class="status-${user.status}">${user.status}</span></td>
                            <td>
                                <c:if test="${sessionScope.user.id != user.id}">
                                    <c:if test="${user.status == 'active'}">
                                        <a href="${pageContext.request.contextPath}/admin/updateUserStatus?userId=${user.id}&status=banned" class="btn-warning">封禁</a>
                                    </c:if>
                                    <c:if test="${user.status == 'banned'}">
                                        <a href="${pageContext.request.contextPath}/admin/updateUserStatus?userId=${user.id}&status=active" class="btn-success">解封</a>
                                    </c:if>
                                    <a href="${pageContext.request.contextPath}/admin/deleteUser?id=${user.id}" class="btn-danger" onclick="return confirm('确定要删除用户 ${user.username} 吗？此操作不可恢复！')">删除</a>
                                </c:if>
                                 <c:if test="${sessionScope.user.id == user.id}">
                                    <span>(当前账户)</span>
                                 </c:if>
                            </td>
                        </tr>
                    </c:forEach>
                </tbody>
            </table>
        </div>
    </main>
</div>

</body>
</html> 